<?php
session_start();
include($_SESSION['document_root']."php/auth.php");
include($_SESSION['document_root']."php/mysql.php");
$pathimg="/img/icons/";
$cnx= new mycnx();
$res= $cnx->select("SELECT * FROM t_menus ORDER BY orden")or die ("error en select 1");
print "<!DOCTYPE html>";
print "<html>";
print "<head>";
print "<meta charset='UTF-8'>";
print "<link rel='stylesheet' type='text/css' href='/css/general.css' />";
print"<link rel='stylesheet' type='text/css' href='/css/menu.css' />";
print "<script src='/js/menu.js' type='text/javascript'></script>";
print "<title>Portal</title>";
print "</head>";
print "<body>";
print "<div class='menu' align='center'>";
if ($res->num_rows > 0){
    while ($row = mysqli_fetch_assoc($res)){
	print "<div class='tmenu' onclick='ocultarmenu(\"tsubmenu".$row['id_menu']."\")'>";
	print "<img src='".$pathimg.$row['img']."' height='22' width='22'>";
	print $row['menu']=ucfirst($row['menu']);
	print "</a></div>";
	print "<div id='tsubmenu".$row['id_menu']."' style='display:none;'>";
	$ress= $cnx->select("SELECT * FROM t_submenu WHERE id_tmenu='$row[id_menu]' ORDER BY orden")or die ("error en select 2");
	if ($ress->num_rows > 0){
					
                            while ($roww = mysqli_fetch_assoc($ress)){
                                       $roww['submenu']=ucfirst($roww['submenu']);
		print "<div class='tsubmenu' align='left'>";
		print "<p><img src='".$pathimg.$roww['img']."' height='22' width='22'>";
		print "<a href='".$roww['link']."' target='principal'>".$roww['submenu']."</a></p>";
		print "</div>";
	}
	}
	print "</div>";
}
}
print "</div>";
print "</body>";
print "</html>";
$res->close();
?>